/**
 * 处理发送请求的Action::GET
 * 扔一个drifting状态的瓶子到系统中
 * Author: frogcherry
 * Email: frogcherry@gmail.com
 * created: 2011.12.08
 */

var mongoDao = require("../MongoDao.js");
var pieCenter = require("../cache/PieCenter.js");

var SendAction = exports;

SendAction.handle = function(urlObj){

	return function (req, res) {
		var uid = urlObj.query.uid;
		var title = urlObj.query.title;
		var content = urlObj.query.content;
		if (uid && title && content) {
			var msg = {"senderId" : uid,
					"title" : title,
					"content" : content,
					"landed" : 0};
			mongoDao.db.drifting_msg.insert(msg, function(){
				pieCenter.driftingCnt += 1;
				res.simpleJSON(200, {"type" : "ok"});//请求错误
			});
		} else {
			res.simpleJSON(200, {"type" : "error", "error": "204" });//请求错误
		}
	  };
};

